import scrapy

from weinian_jichi.items import  WeinianJichiItem

class WeinianspiderSpider(scrapy.Spider):
    name = "jichispyder"
    allowed_domains=["jd.com"]
    def start_requests(self):
        url="https://search.jd.com/Search?keyword=%E9%B8%A1%E7%BF%85&qrst=1&suggest=1.his.0.0&wq=%E9%B8%A1%E7%BF%85&stock=1&pvid=da56204f2723438da135832a9871191f&page=11&s=296&click=0"
        yield scrapy.Request(url,callback=self.parse,dont_filter=True)
    def parse(self, response):
        item=WeinianJichiItem()
        info_list=response.xpath('//ul[@class="gl-warp clearfix"]/li')
        for info in info_list:
            item['vender'] = info.xpath('div[@class="gl-i-wrap"]/div[@class="p-shop"]/span/a/@title').extract()
            item['name'] = info.xpath('div[@class="gl-i-wrap"]/div[@class="p-name p-name-type-2"]/a/em/text()').extract()
            item['price'] = info.xpath('div[@class="gl-i-wrap"]/div[@class="p-price"]/strong/i/text()').extract()
            yield item
